package com.njcb.ams.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.njcb.ams.interaction.ProjectInfoManager;
import com.njcb.ams.pojo.dto.ProjectInfoQueryRequest;
import com.njcb.ams.pojo.dto.ProjectInfoQueryResponse;
import com.njcb.ams.pojo.dto.standard.PageResponse;
import com.njcb.ams.pojo.dto.standard.Response;
import com.njcb.ams.store.page.Page;
import com.njcb.ams.store.page.PageHandle;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 需求信息
 * 
 * @author gujx
 *
 */
@RequestMapping("/projectinfo")
@Api(value = "ProjectInfo", tags = "ProjectInfo", description = "需求信息")
@RestController
public class ProjectInfoController {
    @Autowired
    private ProjectInfoManager projectInfoManager;

    @ApiOperation(value = "获取需求列表", notes = "根据任意条件查询应用列表")
    @RequestMapping(value = "projectInfoQuery", method = RequestMethod.POST)
    @ResponseBody
    public PageResponse<ProjectInfoQueryResponse> projectInfoQuery(Page inPage,
	    ProjectInfoQueryRequest request) {
	// 开始分页
	PageHandle.startPage(inPage);
	List<ProjectInfoQueryResponse> list = projectInfoManager.query(request);
	// 结束分页
	Page page = PageHandle.endPage();
	return PageResponse.build(list, page.getTotal());
    }

    /**
     * 
     * 方法功能描述：保存需求信息
     * 
     * @param projectInfoReq
     * @return
     */
    @RequestMapping(value = "projectInfoSave", method = RequestMethod.POST)
    @ResponseBody
    public Response projectInfoSave(ProjectInfoQueryRequest projectInfoReq) {
	projectInfoManager.saveProjectInfo(projectInfoReq);
	return Response.buildSucc();
    }

    @ApiOperation(value = "删除需求", notes = "删除需求信息")
    @RequestMapping(value = "projectInfoRemove", method = RequestMethod.POST)
    @ResponseBody
    public Response projectInfoRemove(ProjectInfoQueryRequest projectInfo) {
	projectInfoManager.deleteProjectInfo(projectInfo);
	return Response.buildSucc();
    }

    @ApiOperation(value = "提交需求", notes = "提交需求信息")
    @RequestMapping(value = "projectInfoCommit", method = RequestMethod.POST)
    public Response projectInfoCommit(ProjectInfoQueryRequest projectInfo) {
	projectInfoManager.commitProjectInfo(projectInfo);
	return Response.buildSucc();
    }

}
